package com.dream.keigezhushou.Activity.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.RelativeLayout;

import com.dream.keigezhushou.Activity.GlobalConst.GlobalConst;
import com.dream.keigezhushou.Activity.Uiutils.PrefUtils;
import com.dream.keigezhushou.R;

public class SplashActivity extends AppCompatActivity {

//    @BindView(R.id.tv_versions)
//    TextView mTvVersions;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_splash);
        RelativeLayout rl = (RelativeLayout) findViewById(R.id.activity_splash);

        AlphaAnimation animation = new AlphaAnimation(0.3f,1.0f);
        animation.setDuration(2000);
        animation.setFillAfter(true);
        rl.startAnimation(animation);

        //动画的监听
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {

                // 判断是否是第一次打开应用
                boolean isFirstIn = PrefUtils.getBoolean(getApplicationContext(), GlobalConst.PREFUL_ISFIRSTIN, true);
                if (isFirstIn) {
                    Intent intent = new Intent();
                    intent.setClass(SplashActivity.this, GuideActivity.class);
                    startActivity(intent);
                } else {
                    Intent intent = new Intent();
                    intent.setClass(SplashActivity.this, MainActivity.class);
                    startActivity(intent);
                }

                finish();

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

    }
}
